package cn.lanca.gof6_10._06proxy.case1.proxy;

import com.example.demo.gof6_10._06proxy.case1.abstract_subject.Subject;
import com.example.demo.gof6_10._06proxy.case1.real_subject.RealSubject;

/**
 * Proxy代理具体实现
 *
 * @author meihongliang
 * @since 2020/8/7 17:41
 */
public class Proxy implements Subject {
    /**
     * realSubject 真正干活儿的对象
     */
    private RealSubject realSubject;
    /**
     * 另外干活儿的对象
     */
    private RealSubject realSubjectB;

    /**
     * request
     */
    @Override
    public void request() {
        if (realSubject == null) {
            realSubject = new RealSubject();
        }
        preRequest();
        realSubject.request();
        postRequest();
    }

    public void preRequest() {
        System.out.println("访问真实主题之前的预处理。");
    }

    public void postRequest() {
        System.out.println("访问真实主题之后的后续处理。");
    }
}
